﻿using Microsoft.Xna.Framework;

namespace Innovator
{
	public static class MathUtil
	{
		public static Matrix CreateProjectionMatrix()
		{
			return Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
				(float)Engine.GraphicsDevice.Viewport.Width /
				(float)Engine.GraphicsDevice.Viewport.Height, .01f, 1000000);
		}
		public static Matrix CreateWorldMatrix(Vector3 Translation)
		{
			return CreateWorldMatrix(Translation, Matrix.Identity);
		}
		public static Matrix CreateWorldMatrix(Vector3 Translation, Matrix Rotation)
		{
			return CreateWorldMatrix(Translation, Rotation, Vector3.One);
		}
		public static Matrix CreateWorldMatrix(Vector3 Translation, Matrix Rotation, Vector3 Scale)
		{
			return Matrix.CreateScale(Scale) *
				Rotation *
				Matrix.CreateTranslation(Translation);
		}
		public static Matrix Vector3ToMatrix(Vector3 Rotation)
		{
			return Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z);
		}
		public static Vector3 MatrixToVector3(Matrix Rotation)
		{
			Quaternion q = Quaternion.CreateFromRotationMatrix(Rotation);
			return new Vector3(q.X, q.Y, q.Z);
		}
	}
}